<?php
  INCLUDE "F_CONX.php";

  $V_ANIO     = $HTTP_POST_VARS["V_ANIO"];
  $V_MES      = $HTTP_POST_VARS["V_MES"];
  $V_ZONA     = $HTTP_POST_VARS["V_ZONA"];

  $MS_SQL        = "SELECT * FROM intercambio where area = '$V_ZONA'";
  $MS_RESULT     = MYSQL_QUERY($MS_SQL);
  WHILE($A_DINT  = MYSQL_FETCH_ARRAY($MS_RESULT))
  {
     $V_ENE      = $HTTP_POST_VARS["V_ENE".$A_DINT[1]];
     $V_DEM      = $HTTP_POST_VARS["V_DEM".$A_DINT[1]];
     $V_FP       = $HTTP_POST_VARS["V_FP". $A_DINT[1]];
     $V_IMP      = $HTTP_POST_VARS["V_IMP".$A_DINT[1]];
     $V_IVA      = ($V_IMP*(.15));
     $V_TOT      = $V_IMP + $V_IVA;
     $MS_SQL2     = "UPDATE datosi SET energia='$V_ENE', demanda='$V_DEM', fp='$V_FP', importe='".ROUND($V_IMP,2)."', iva='".ROUND($V_IVA,2)."', total='".ROUND($V_TOT,2)."' WHERE llave='$V_ZONA$A_DINT[1]' AND anio=$V_ANIO AND mes=$V_MES ";
     $MS_RESULT2  = MYSQL_QUERY($MS_SQL2);
  }
  HEADER ("LOCATION: P_BODY.php");
?>
